<?php

header('Content-Type: text/html; charset=UTF-8');

$server = "localhost";
$username = "root";
$password = "";
$database = "gesproy";

$con = mysql_connect($server, $username, $password) or die("No se conecto: " . mysql_error());

mysql_select_db($database, $con);
//$id = $_GET['id'];
$sql = "SELECT * FROM grupo where IDGRUPO =:id order by 1 asc";

try {
    $dbh = new PDO("mysql:host=$server;dbname=$database", $username, $password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam("id", $_GET['id']);
    $stmt->execute();
    $grupousuario = array();
    while($fila = $stmt->fetchObject()){
        $grupousuario[] = $fila;
    }
    $dbh = null;
    echo '{"item":' . json_encode($grupousuario) . '}';
} catch (PDOException $e) {
    echo '{"error":{"text":' . $e->getMessage() . '}}';
}

mysql_close($con);
?>